package freeframe.test;

import freeframe.speech.MyRecord;

import java.util.LinkedList;
import java.util.Queue;

public class SpeechReceiver implements Runnable{

    private static Queue<String> queue = new LinkedList<>();

    private static boolean begin = false;

    private SpeechReceiver(){}

    public static void start(){
        begin = true;
    }
    public static void stop(){
        begin = false;
    }

    public static String getContent(){
        return queue.poll();
    }

    @Override
    public void run() {
        //创造一个实例
        MyRecord mr = new MyRecord();
        mr.setVisible(false);

        while (true){
            if (begin){
                mr.operateStart();
                try {
                    Thread.sleep(2000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                String result = mr.operateStop();
                if (null != result){
                    queue.offer(result);
                }
            }
        }
    }
    public static void initial(){
        new Thread(new SpeechReceiver()).start();
    }



}
